import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import Antd from 'ant-design-vue';
import 'ant-design-vue/dist/antd.css';
import * as Icons from '@ant-design/icons-vue';
// 配置的多环境
import Axios from 'axios';
import {Tool} from "@/util/tool";
// 配置Axios的默认前缀路径
Axios.defaults.baseURL = process.env.VUE_APP_SERVER

/**
 * axios拦截器
 */
 Axios.interceptors.request.use(function (config) {
    console.log('请求参数：', config);
    const token = store.state.user.token;
    if (Tool.isNotEmpty(token)) {
        (config as any).headers.token = token;
        console.log("请求headers增加token:", token);
    }
    return config;
}, error => {
    return Promise.reject(error);
});

//  并且使用Antd
const app = createApp(App);
app.use(store).use(Antd).use(router).mount('#app');

// 全局使用图标
const icons: any = Icons;
for (const i in icons) {
  app.component(i, icons[i]);
}

